﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ocmf.Types;

namespace Ocmf.Forms
{
    public partial class EditCounter : Form
    {
        public Counter Counter { get; set; }

        public EditCounter(Counter counter)//, string[] CurrentCounters)
        {
            Counter = counter;
            InitializeComponent();
            incrementRadioButton.Checked = counter.Increment;
            decrementRadioButton.Checked = !counter.Increment;
            countersComboBox.Items.AddRange(((Experiment)counter.TreeView).Counters.ToArray());
            countersComboBox.SelectedItem = counter.Alias;
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            Counter.Alias = countersComboBox.Text;
            if (!((Experiment)Counter.TreeView).Counters.Contains(countersComboBox.Text))
                ((Experiment) Counter.TreeView).Counters.Add(countersComboBox.Text);
            Counter.Increment = incrementRadioButton.Checked;
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
    }
}
